<template>
  <div class="ablum-item">
    <scroll ref="scroll"
            class="ablum-scroll">
      <!-- 对专辑的描述 -->
      <div class="desc">
        <div class="top">
          <div class="left">
            <div class="image">
              <img :src="declist.pic"
                   alt="">
            </div>
          </div>
          <div class="rigth">
            <span class="zj"></span>
            <span class="album-name">{{declist.name}}</span>
            <p class="artist">歌手：{{declist.artist}}</p>
            <p class="time">发行时间：{{publishTime}}</p>
            <p class="company">发行公司：{{declist.company}}</p>
            <div class="bofang"
                 @dblclick="PlayMusic()">
              <img src="~assets/img/playmusic/bofang.svg"
                   alt />
              全部播放
            </div>
          </div>
        </div>
        <div class="buttom"
             :class="{fold:fold}">
          <p class="title">专辑介绍：</p>
          <p class="shuom">{{declist.description}}</p>
          <div class="toggle-fold"
               @click="fold=!fold">
            <span class="zk"
                  v-if="fold">展开 <i></i></span>
            <span class="sq"
                  v-if="!fold">收起<i></i></span>
          </div>
        </div>
      </div>
      <!-- 包含的歌曲 -->
      <div class="Hasmusic">
        <span class="title2">包含歌曲列表</span> <span class="len">{{musiclist.length}}首歌</span>
        <table cellspacing='0'>
          <thead>
            <tr>
              <td></td>
              <td>歌曲列表</td>
              <td>时长</td>
              <td>歌手</td>
            </tr>
          </thead>
          <tbody>
            <tr v-for="(item,index) in musiclist"
                :key="index"
                :class="{backColor:setBackColor(index)}"
                @dblclick="PlayMusic(index)">
              <td>
                {{setSerial(index)}}
                <span v-if="playIndex==index"
                      class="isshow"></span>
                <span v-else></span>
              </td>
              <td>{{item.name}}</td>
              <td>{{item.time}}</td>
              <td>{{item.artist}}</td>
            </tr>
          </tbody>
        </table>
      </div>
      <!-- 热评论 -->
      <div class="recommend">
        <div class="rec-title">
          <span class="title3">评论</span>
          <span class="len">{{this.recommends.length}}共条评论</span>
        </div>
        <recommends :recommends='recommends' :id='id' />
      </div>
    </scroll>
  </div>
</template>

<script>
import { _getNewestDetail, AlbumDetail, AlbumSongDetail, _getAlbumrecommends } from 'network/detail'
import Scroll from 'components/common/scroll/Scroll.vue';
import { tableMixin } from 'mixin/tableMixin';
import { indexMixin } from 'mixin/indexMixin';
import { playMixin } from 'mixin/playMixin';
import Recommends from './Recommends';
import moment from 'moment';
export default {
  components: { Scroll, Recommends },
  name: 'AlbumItem',
  data () {
    return {
      musiclist: [],
      // 基本信息
      declist: {},
      id: 0,
      // 评论
      recommends: [],
      fold: true
    }
  },
  computed: {
    publishTime () {
      return moment(this.declist.publishTime).format('YYYY-MM-DD')
    }
  },
  mixins: [tableMixin, indexMixin, playMixin],
  created () {
    this.id = this.$route.params.id;
    _getNewestDetail(this.id).then(res => {
      const dec = new AlbumDetail(res.data.album)
      this.declist = dec;
      for (var i of res.data.songs) {
        const song = new AlbumSongDetail(i);
        this.musiclist.push(song);
      }
    })
    _getAlbumrecommends(this.id).then(res => {
      this.recommends = res.data.hotComments;
    })
  }
}
</script>

<style scoped>
.ablum-item {
  width: 100%;
  height: 100%;
  padding: 30px 50px;
  box-sizing: border-box;
  color: #000 !important;
}
.ablum-scroll {
  height: 100%;
  overflow: hidden;
}
.top {
  width: 100%;
  display: flex;
  height: 180px;
}
.top .left {
  width: 230px;
  float: left;
}
.top .image {
  width: 209px;
  height: 177px;
  background: url("../../../assets/img/newest/coverall.png") no-repeat;
  background-position: 0 -986px;
}
.top .left img {
  width: 177px;
  height: 177px;
}
.top .rigth {
  flex: 1;
  float: left;
  height: 100%;
}
.rigth .zj {
  display: inline-block;
  width: 54px;
  height: 24px;
  background: url("../../../assets/img/newest/icon.png") no-repeat;
  background-position: 0 -186px;
}
.rigth .bofang {
  width: 100px;
  height: 40px;
  text-align: center;
  line-height: 40px;
  margin-top: 30px;
  background: rgb(197, 4, 4);
  color: #fff;
  border-radius: 5px;
  font-size: 13px;
}
.bofang img {
  width: 24px;
  height: 24px;
  vertical-align: -6px;
}
.rigth .album-name {
  font-size: 20px;
  margin-left: 5px;
  vertical-align: 4px;
}
.rigth p {
  font-size: 14px;
  padding: 3px 0;
}
.buttom {
  position: relative;
  padding: 15px 0;
}
.buttom .title {
  margin: 0px 0 10px 0;
  font-style: 15px;
  font-weight: 700;
}
.buttom .shuom {
  font-size: 13px;
  text-indent: 2em;
}
/* 包含歌曲部分 */
.Hasmusic {
  margin: 30px 0;
  font-size: 12px !important;
}
.Hasmusic .title2 {
  font-size: 20px;
}
.Hasmusic .len {
  padding-left: 30px;
}
.Hasmusic table {
  width: 100%;
  margin-top: 5px;
  border-top: 2px solid #00aa85 !important;
  border: 2px solid #ddd;
  color: #333;
}
.Hasmusic table tr td {
  padding-left: 4px;
}
.Hasmusic thead tr {
  background: #fff;
  height: 40px;
}
.Hasmusic thead tr td {
  border: 1px solid #ccc;
}
.Hasmusic tr td:nth-child(1) {
  width: 70px;
  text-align: left;
  padding: 0 10px;
  color: #999999;
}
.Hasmusic tbody tr {
  background: #fff;
  height: 40px;
}
tbody tr td {
  position: relative;
}
.Hasmusic tr td .isshow {
  background-position: -20px -128px;
}
.Hasmusic tr td span {
  display: inline-block;
  width: 17px;
  height: 17px;
  background: url("../../../assets/img/newest/table.png") no-repeat 0 9999px;
  background-position: 0 -103px;
  position: absolute;
  right: 5px;
  top: 12px;
}
/* 新评论 */
.rec-title {
  border-bottom: 2px solid #00aa85;
}
.recommend .title3 {
  font-size: 20px;
}
.recommend .len {
  padding-left: 30px;
}
.backColor {
  background: #f7f7f7 !important;
}
/* 折叠 */
.fold {
  height: 70px;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
.toggle-fold {
  position: absolute;
  bottom: 0px;
  right: 10px;
  color: #00aa85;
}
/* .zk {
  background: url("../../../assets/img/newest/icon.png") 0px 9999px no-repeat;
}
.zk i {
  width: 11px;
  height: 8px;
  background-position: -65px -520px;
  display: inline-block;
  overflow: hidden;
  vertical-align: middle;
} */
</style>
